package com.xzx.annotation.transaction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author xinzhixuan
 * @version 1.0
 * @date 2025/5/8 18:18
 */
@Service
public class MyService {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void insertSigData() {
        long ts = System.currentTimeMillis() - 1000L * 3600 * 24 * 31 * 3;
        for (int i = 0; i < 40000000; i++) {
            jdbcTemplate.update("insert into datafact.private_dubhe_signal_meeting_statis(collection,service_name,timestamp,data,groupId,meetingId,type) values (?,?,?,?,?, ?,?)", "ff808081526e509201527780a6b10010signal_meeting_statis", "signal", ts, "{\"userCount\":1,\"contentShareUsers\":[],\"annotationUsers\":[],\"recordingUri\":\"\",\"liveId\":\"\",\"whiteboardUri\":\"\",\"attachedGroupId\":\"\",\"rsName\":\"\",\"scheduledEventId\":\"\",\"cloudConfNo\":\"9188001\",\"mpCloudConfNo\":\"\",\"isCallCenterConf\":false,\"isMonitorConf\":false,\"type\":\"ConfStatisReport_Start\",\"meetingId\":\"000-bj1-privateSig2-1176383295498\",\"timestamp\":1738600047929,\"mcName\":\"520ha-mc1\",\"uuid\":\"bj1\",\"domainId\":\"bj1\",\"staticGroup\":false}", "000-bj1-privateSig2-1176383295498", "000-bj1-privateSig2-1176383295498", "UserStatisReport_Start");
            ts = ts - 1L;
        }
    }

    public void insertMmData() {
        long ts = System.currentTimeMillis() - 1000L * 3600 * 24 * 31 * 3;
        for (int i = 0; i < 40000000; i++) {
            jdbcTemplate.update("insert into datafact.private_dubhe_meeting_controller_meeting_record(collection,service_name,timestamp,data,meetingId,operatorIdentify,operationTime) values (?,?,?,?,?, ?,?)", "ff808081526e509201527780a6b10010meeting_controller_meeting_record", "mm", ts - 1, "{\"meetingId\":\"000-bj1-privateSig2-1176450404357\",\"conferenceNo\":\"9080963278\",\"groupNo\":null,\"meetingName\":\"SDK_MMS_TEST\",\"eventType\":\"INFO\",\"eventSource\":\"MMS_SDK\",\"operationTime\":1739224892223,\"operationType\":\"SDK_FORCE_HANG_UP_MEETING\",\"operationResult\":null,\"failureReason\":null,\"operatorDeviceId\":null,\"operatorDeviceName\":null,\"operatorDeviceType\":null,\"operatorIdentify\":null,\"targetDeviceId\":null,\"targetDeviceName\":null,\"targetDeviceType\":null,\"targetDeviceNo\":null,\"version\":\"1\",\"otherInfo\":null,\"role\":\"none\",\"fromGroupNo\":null,\"fromGroupName\":null,\"toGroupNo\":null,\"toGroupName\":null}", "000-bj1-privateSig2-1176450404357", "", ts);
            ts--;
        }
    }

//    @Transactional
    public void insertData() {
        System.out.println("insertData before");
        jdbcTemplate.update("insert into datafact.private_dubhe_meeting_controller_meeting_record(collection,service_name,timestamp,data,meetingId,operatorIdentify,operationTime) values (?,?,?,?,?, ?,?)", "ff808081526e509201527780a6b10010meeting_controller_meeting_record", "mm", -1, "{\"meetingId\":\"000-bj1-privateSig2-1176450404357\",\"conferenceNo\":\"9080963278\",\"groupNo\":null,\"meetingName\":\"SDK_MMS_TEST\",\"eventType\":\"INFO\",\"eventSource\":\"MMS_SDK\",\"operationTime\":1739224892223,\"operationType\":\"SDK_FORCE_HANG_UP_MEETING\",\"operationResult\":null,\"failureReason\":null,\"operatorDeviceId\":null,\"operatorDeviceName\":null,\"operatorDeviceType\":null,\"operatorIdentify\":null,\"targetDeviceId\":null,\"targetDeviceName\":null,\"targetDeviceType\":null,\"targetDeviceNo\":null,\"version\":\"1\",\"otherInfo\":null,\"role\":\"none\",\"fromGroupNo\":null,\"fromGroupName\":null,\"toGroupNo\":null,\"toGroupName\":null}", "000-bj1-privateSig2-1176450404357", "", -1);
        int  i = 1 / 0;
        jdbcTemplate.update("insert into datafact.private_dubhe_meeting_controller_meeting_record(collection,service_name,timestamp,data,meetingId,operatorIdentify,operationTime) values (?,?,?,?,?, ?,?)", "ff808081526e509201527780a6b10010meeting_controller_meeting_record", "mm", -2, "{\"meetingId\":\"000-bj1-privateSig2-1176450404357\",\"conferenceNo\":\"9080963278\",\"groupNo\":null,\"meetingName\":\"SDK_MMS_TEST\",\"eventType\":\"INFO\",\"eventSource\":\"MMS_SDK\",\"operationTime\":1739224892223,\"operationType\":\"SDK_FORCE_HANG_UP_MEETING\",\"operationResult\":null,\"failureReason\":null,\"operatorDeviceId\":null,\"operatorDeviceName\":null,\"operatorDeviceType\":null,\"operatorIdentify\":null,\"targetDeviceId\":null,\"targetDeviceName\":null,\"targetDeviceType\":null,\"targetDeviceNo\":null,\"version\":\"1\",\"otherInfo\":null,\"role\":\"none\",\"fromGroupNo\":null,\"fromGroupName\":null,\"toGroupNo\":null,\"toGroupName\":null}", "000-bj1-privateSig2-1176450404357", "", -2);
        System.out.println("insertData after");
    }
}
